/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package ecom.beans.store;

import ecom.beans.account.*;
import ecom.beans.address.*;
import ecom.beans.dish.*;


import java.io.Serializable;
//import javax.naming.Context;
//import javax.naming.InitialContext;
import java.util.List;
import javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
//import javax.persistence.EntityManager;
import javax.persistence.Id;
//import javax.persistence.JoinColumn;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.OneToOne;
//import javax.transaction.UserTransaction;

/**
 *
 * @author Tian
 */


@NamedQueries({
    
    @NamedQuery(name = "findAllStores",
    query = "SELECT store FROM StoreEntity store"),
            
    @NamedQuery(name = "findStoreById",
    query = "SELECT store FROM StoreEntity store WHERE store.id = :id"),
            
    @NamedQuery(name = "findStoreByName",
    query = "SELECT store FROM StoreEntity store WHERE store.storeName = :storeName")    
})        
@Entity
public class StoreEntity implements Serializable {
    private static final long serialVersionUID = 1L;
    
    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    private Long id;
    
    private String storeName;
    private int seatsNumber;
    private int deliverymenNumber;
    
    @OneToOne(cascade ={CascadeType.ALL})
    private AddressEntity storeAddress;
    
    @OneToOne(cascade ={CascadeType.ALL})
    private AccountEntity storeAccount;
    
	//don need this
    //@OneToMany(cascade ={CascadeType.ALL})
    //private DishEntity storeDish;

  
    public AddressEntity getStoreAddress() {
        return storeAddress;
    }

    public void setStoreAddress(AddressEntity storeAddress) {
        this.storeAddress = storeAddress;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public int getDeliverymenNumber() {
        return deliverymenNumber;
    }

    public void setDeliverymenNumber(int deliverymenNumber) {
        this.deliverymenNumber = deliverymenNumber;
    }

    public int getSeatsNumber() {
        return seatsNumber;
    }

    public void setSeatsNumber(int seatsNumber) {
        this.seatsNumber = seatsNumber;
    }

    
    public Long getId() {
        return id;
    }

    public AccountEntity getStoreAccount() {
        return storeAccount;
    }

    public void setStoreAccount(AccountEntity storeAccount) {
        this.storeAccount = storeAccount;
    }

    public String getStoreName() {
        return storeName;
    }

    public void setStoreName(String storeName) {
        this.storeName = storeName;
    }
    
    @Override
    public int hashCode() {
        int hash = 0;
        hash += (id != null ? id.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof StoreEntity)) {
            return false;
        }
        StoreEntity other = (StoreEntity) object;
        if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "ejb.store.StoreEntity[id=" + id + "]";
    }

}
